package com.training.web.controller.comtent;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.training.common.annotation.Log;
import com.training.common.core.controller.BaseController;
import com.training.common.core.domain.AjaxResult;
import com.training.common.enums.BusinessType;
import com.training.content.domain.AssessItemScore;
import com.training.content.service.IAssessItemScoreService;
import com.training.common.utils.poi.ExcelUtil;
import com.training.common.core.page.TableDataInfo;

/**
 * 考核项得分Controller
 * 
 * @author training
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/assess/score")
public class AssessItemScoreController extends BaseController
{
    @Autowired
    private IAssessItemScoreService assessItemScoreService;

    /**
     * 查询考核项得分列表
     */
    @PreAuthorize("@ss.hasPermi('assess:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssessItemScore assessItemScore)
    {
        startPage();
        List<AssessItemScore> list = assessItemScoreService.selectAssessItemScoreList(assessItemScore);
        return getDataTable(list);
    }

    /**
     * 导出考核项得分列表
     */
    @PreAuthorize("@ss.hasPermi('assess:score:export')")
    @Log(title = "考核项得分", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AssessItemScore assessItemScore)
    {
        List<AssessItemScore> list = assessItemScoreService.selectAssessItemScoreList(assessItemScore);
        ExcelUtil<AssessItemScore> util = new ExcelUtil<AssessItemScore>(AssessItemScore.class);
        return util.exportExcel(list, "考核项得分数据");
    }

    /**
     * 获取考核项得分详细信息
     */
    @PreAuthorize("@ss.hasPermi('assess:score:query')")
    @GetMapping(value = "/{scoreId}")
    public AjaxResult getInfo(@PathVariable("scoreId") Long scoreId)
    {
        return AjaxResult.success(assessItemScoreService.selectAssessItemScoreByScoreId(scoreId));
    }

    /**
     * 新增考核项得分
     */
    @PreAuthorize("@ss.hasPermi('assess:score:add')")
    @Log(title = "考核项得分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssessItemScore assessItemScore)
    {
        return toAjax(assessItemScoreService.insertAssessItemScore(assessItemScore));
    }

    /**
     * 修改考核项得分
     */
    @PreAuthorize("@ss.hasPermi('assess:score:edit')")
    @Log(title = "考核项得分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssessItemScore assessItemScore)
    {
        return toAjax(assessItemScoreService.updateAssessItemScore(assessItemScore));
    }

    /**
     * 删除考核项得分
     */
    @PreAuthorize("@ss.hasPermi('assess:score:remove')")
    @Log(title = "考核项得分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scoreIds}")
    public AjaxResult remove(@PathVariable Long[] scoreIds)
    {
        return toAjax(assessItemScoreService.deleteAssessItemScoreByScoreIds(scoreIds));
    }
}
